package com.ssy.lingxi.product.repository;

import com.ssy.lingxi.product.entity.Goods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;

/**
 * 货品持久化层
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/6/22
 */
public interface GoodsRepository extends JpaRepository<Goods,Long>, JpaSpecificationExecutor<Goods> {
    Page<Goods> findByMemberIdAndMemberRoleIdAndNameContainingOrderByIdDesc(Long memberId, Long memberRoleId, String name, Pageable page);

    List<Goods> findByMemberIdAndMemberRoleIdAndCodeAndIdNot(Long memberId, Long memberRoleId, String code, Long id);

    List<Goods> findByMemberIdAndMemberRoleIdAndCode(Long memberId, Long memberRoleId, String code);

    List<Goods> findByMemberIdAndMemberRoleIdAndCodeIn(Long memberId, Long memberRoleId, List<String> codes);

    List<Goods> findByMemberIdAndMemberRoleIdAndIdIn(Long memberId, Long memberRoleId, List<Long> goodsIdList);

    Boolean existsByBrandId(Long brandId);

    Goods findByMemberIdAndMemberRoleIdAndId(Long memberId, Long memberRoleId, Long id);

    List<Goods> findByMemberIdAndMemberRoleId(Long memberId, Long memberRoleId);

    List<Goods> findByMaterialGroupId(Long materialGroupId);
}
